package javase0906;

import javase0829.LoginClient;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.List;

public class ClientBunny {
    public void initDish(List<Dish> menu) {
        try {
            Socket socket = new Socket("127.0.0.1", 8888);
            InputStream is = socket.getInputStream();
            ObjectInputStream ois = new ObjectInputStream(is);
            Object in = ois.readObject();

            List<Dish> temp = (List<Dish>) in;
            for (Dish d : temp) {
                menu.add(d);
            }

            ois.close();
            is.close();
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
